<include file="Public/head"/>
<style type="text/css">
    #reply_content_div,#reply_keyword_div{display:none;}
</style>
<div class="tableContainer">
	<div class="tablePanel">
		<div class="edit-title" style="height:56px;">
			<!-- 有title-icon1至title-icon14共14个图标可供选择 -->
			<span class="title-icon11"></span>
			<if condition="$_GET['type'] eq '1'">
			<div><h4 style="float:left;margin-left:10px;">首次关注回复<span style="font-size:12px;font-weight:normal;color:#999;">（用户首次关注成功后收到的界面欢迎信息。可以写一些提醒用户的相关操作等。首次回复可以是以文字或图文的形式出现）</span></h4></div>
			<else/>
			<div><h4 style="float:left;margin-left:10px;">无匹配回复<span style="font-size:12px;font-weight:normal;color:#999;">（用户发送关键字/关键词后，并无匹配结果后的返回信息。可以写一些提醒用户的相关操作等）</span></h4></div>
			</if>
		</div>
		<form role="form" method="post" id="autoreplyform">
    		<input type="hidden" name="info[id]" value="<{$item.id}>">
            <input type="hidden" name="info[type]" value="<{:I('get.type')}>">
    		<div class="edit-body">
    	        <if condition="$_GET['type'] eq '1'">
        	        <div class="set-line">
        	            <div class="set-title">回复类型：</div>
        	            <div class="set-ctrl">
        	                <select id="is_content" name="info[is_content]">
        	                    <option value="1" <{:$item['is_content']!='2'?'selected': ''}>>文本消息</option>
        	                    <option value="2" <{:$item['is_content']=='2'?'selected': ''}>>绑定关键词</option>
        	                </select>
        	            </div>
        	        </div>
    	        </if>
    	        <div id="reply_content_div" class="set-line" <if condition="$item['is_content'] neq '2'">style="display:block;"</if> >
    	             <div class="set-title">回复内容：</div>
    	            <div class="set-ctrl">
    	                <textarea id="reply_content" style="width:400px;height:150px;" name="info[content]"><{$item.content}></textarea>
    	            </div>
    	        </div>
    	        <div id="reply_keyword_div" class="set-line" <if condition="$item['is_content'] eq '2'">style="display:block;"</if> >
    	             <div class="set-title">规则：</div>
    	            <div class="set-ctrl">
    	                <input id="reply_keyword" name="info[keyword]" type="text" value="<{$item.keyword}>" />
    	                <span style="color:#999">&nbsp;&nbsp;请先在关键词回复设置好规则内容</span>
    	            </div>
    	        </div>
    	        <div class="set-line">
    	            <div class="set-title">状态：</div>
    	            <div class="set-ctrl">
    	                <label class="radioLabel">
    	                    <input type="radio" value="1" name="info[state]" <{:$item['state']!='2'?'checked': ''}> /> 开启
    	                </label>
    	                <label class="radioLabel">
    	                    <input type="radio" value="2" name="info[state]" <{:$item['state']=='2'?'checked': ''}> /> 关闭
    	                </label>
    	            </div>
    	            <div style="clear:both;"></div>
    	        </div>
    			<div class="clearfloat"></div>
    	        <div class="save">
    				<span onclick="saveform(this)" class="saveBtn" id="saveBtn">提交保存</span>
    			</div>
        	</div>
    	</form>
    </div>
</div>
<script type="text/javascript">
    function saveform(obj) {
        if ($("#reply_content").val() == '' && $("#reply_keyword").val() == '') {
            note_info('请填写回复内容或规则', obj, 'warn');
            return;
        }

        $.ajax({
            type: "POST",
            url: "<{:U('Wechat/WxAutoReply/add')}>",
            data: $('#autoreplyform').serialize(),
            success: function(res){
                if(res.status == 1){
                    note_info(res.info, obj);
                    setTimeout('location.reload()', 1200);
                }else{
                    note_info(res.info, obj, 'warn');
                }
            }
        });
    }

    $(document).ready(function () {
        $('#is_content').change(function () {
            if ($(this).val() == '1') {
                $('#reply_keyword_div').hide();
                $('#reply_content_div').show();
            } else {
                $('#reply_content_div').hide();
                $('#reply_keyword_div').show();
            }
        });
    });
</script>
<include file="Public/foot"/>